#include<bits/stdc++.h>
using namespace std;

long long string_to_int(string s, long long base) {
    long long ans = 0, n = 0;
    for (int i = s.size() - 1; i >= 0; i--) {
        ans += (s[i] - '0') * pow(base, n);
        n++;
    }
    return ans;
}

int main() {
    long long p, q, r;
    cin >> p >> q >> r;
    string sp, sq, sr;
    sp = to_string(p);
    sq = to_string(q);
    sr = to_string(r);
    for (long long n = 2; n <= 16; n++) {
        if (string_to_int(sp, n) * string_to_int(sq, n) == string_to_int(sr, n)) {
            cout << n << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}